import type { Dayjs } from "dayjs";
import DatePicker from "./date-picker";

export type DateRange = {
	begin?: string | number | Date | Dayjs;
	end?: string | number | Date | Dayjs;
};

interface DateRangeProps {
	value?: DateRange;
	onChange?: (value: DateRange) => void;
}

export default function DateRange({ value = {}, onChange }: DateRangeProps) {
	return (
		<div>
			<DatePicker
				value={value.begin}
				maxDate={value.end}
				onChange={(v) => onChange?.({ ...value, begin: v })}
				placeholder="请选择开始日期"
				className="w-[150px]"
			/>
			<DatePicker
				value={value.end}
				minDate={value.begin}
				onChange={(v) => onChange?.({ ...value, end: v })}
				placeholder="请选择结束日期"
				className="w-[150px]"
			/>
		</div>
	);
}
